/**
 * Project Name:ConsoleController.java
 * File Name:ConsoleController.java
 * Date:2018/7/24 下午7:02
 * Copyright (c) ${year}, zhang.xiangyu@foxmail.com All Rights Reserved.
*/
package com.dyrj.base.system.console.controller;

import com.dyrj.base.system.console.service.ConsoleService;
import com.dyrj.base.system.user.model.SysUser;
import com.dyrj.vo.ResultMsg;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Title: ConsoleController.java
 * @Description: todo(控制台)
 * @Author
 * @Date 2018/7/24 下午7:02 
 * @Version V1.0   
 */
@Controller
@RequestMapping("/system/console")
public class ConsoleController {
    @Resource
    private ConsoleService service;

    /** 
     * @Title: index
     * @Description: todo(主页)
     * @Params: []
     * @Return java.lang.String    返回类型 
     * @Author
     * @Date 2018/7/24 下午7:03
     */
    @GetMapping("/index")
    public String index() {
        return "system/console/console";
    }

    /**
     * @Title: add
     * @Description: todo()
     * @Params: [userPubRsa: 用户公钥]
     * @Return com.dyrj.vo.ResultMsg    返回类型
     * @Author
     * @Date 2018/8/24 上午11:27
     */
    @PostMapping("/")
    @ResponseBody
    public ResultMsg add(SysUser record) {
        return service.add(record);
    }

    /**
     * @Title: info
     * @Description: todo(查看用户与平台公钥)
     * @Params: [id: 用户ID]
     * @Return com.dyrj.vo.ResultMsg    返回类型
     * @Author
     * @Date 2018/8/24 下午10:06
     */
    @GetMapping("/{id}")
    @ResponseBody
    public ResultMsg info(@PathVariable Long id) {
        return service.info(id);
    }

    /**
     * @Title: createRsa
     * @Description: todo()
     * @Params: []
     * @Return com.dyrj.vo.ResultMsg    返回类型
     * @Author
     * @Date 2018/8/25 上午10:30
     */
    @GetMapping("/creatersa")
    public String createRsa(ModelMap modelMap) {
        modelMap.put("rsa", service.createRsa());
        return "system/console/creatersa";
    }
}
